<?php
	/**
	 * get data from db and generate html options
	 *
	 */
	class DataUtil{
		
		public static function getOptionsForPublishers(){
			$pubmodel = new Publisher();
			$publishers = $pubmodel->getAllPublishers();
			if(0 == count($publishers))
				return null;
			return Util::listData($publishers, 'id', 'name');
		}

		public static function getOptionsForSubs(){
			$submodel = new Sub();
			$subs = $submodel->getAllSubs();
			if(0 == count($subs))
				return null;
			return Util::listData($subs, 'id', 'name');
		}
		
		public static function getOptionsForOffers(){
			$offermodel = new Offer();
			$offers = $offermodel->getOffersAsList();
			if(0 == count($offers))
				return null;
			return Util::listData($offers, 'id', 'name');
		}
		
		public static function getOptionsForMonetization(){
			$model = new Monetization();
			$monetizations = $model->getAllMonetizationsAsList();
			if(0 == count($monetizations))
				return null;
			return Util::listDataMonetizations($monetizations);
		}
		
		/**
		 * generate dropdownlist options(like "offername + type + $price")
		 * eg: "Offer one, CMA, $12.00"
		 * 
		 */
		public static function getOptionsForOffersList(){
			$offermodel = new Offer();
			$offers = $offermodel->getOffersAsDetailedList();
			if(0 == count($offers))
				return null;
			return Util::listDataOffers($offers);
		}
		
		public static function getOptionsForSites(){
			$sitemodel = new Site();
			$sites = $sitemodel->getAllSitesAsList();
			if(0 == count($sites))
				return null;
			
			$sites[] = array('id'=>'0', domain=>'All');
			return Util::listData($sites, 'id', 'domain');
		}
		
		public static function getOptionsForAdvertisers() {
			$advertiserModel = new Advertiser();
			$advertisers = $advertiserModel->getAllAdvertisers();
			if (0 == count($advertisers))
				return null;
			return Util::listData($advertisers, 'id', 'name');
		}
		
	}